import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  const HomeList({super.key, required this.notifyList});

  final List notifyList;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 标题
        Row(
          children: [
            Image.asset(
              'images/notice@2x.png',
              width: 24,
              height: 24,
            ),
            const Text(
              '社区',
              style: TextStyle(
                color: Colors.black,
                fontWeight: FontWeight.w700,
              ),
            ),
            const Text(
              '公告',
              style: TextStyle(
                color: Colors.amber,
                fontWeight: FontWeight.w700,
              ),
            ),
          ],
        ),
        // 列表
        notifyList.isEmpty
            ? const Center(
                child: CircularProgressIndicator(
                  color: Color.fromARGB(255, 99, 143, 171),
                ),
              )
            : ListView(
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                children: notifyList
                    .map(
                      (item) => GestureDetector(
                        onTap: () {
                          Navigator.pushNamed(
                            context,
                            '/detail',
                            arguments: item['id'],
                          );
                        },
                        child: Container(
                          padding: const EdgeInsets.all(10),
                          margin: const EdgeInsets.only(top: 20),
                          decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(10),
                          ),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                item['title'],
                                style: const TextStyle(
                                  fontWeight: FontWeight.w700,
                                ),
                              ),
                              const SizedBox(height: 5),
                              Text(item['content']),
                              const SizedBox(height: 5),
                              Text(
                                item['createdAt'],
                                style: const TextStyle(
                                  color: Colors.grey,
                                ),
                              )
                              // Text(item['createTime']),
                            ],
                          ),
                        ),
                      ),
                    )
                    .toList(),
              )
      ],
    );
  }
}
